import 'package:agora_rtc_engine/agora_rtc_engine.dart';

import '../../../lib_rtc/rtc/rtc_manager.dart';
import 'rtc_mixin.dart';

class AgoraRtc with RtcMixin {
  @override
  Future<void> init() => RtcManager.instance.init(rtcConfig.rtcToken,
      currUser?.id ?? 0, rtcConfig.lowLatency, onVolumeInfo);

  @override
  Future<void> joinRoom() => RtcManager.instance
      .joinChannel(rtcConfig.rtcToken, rtcConfig.channelId, currUser?.id ?? 0);

  @override
  Future<void> leaveChannel() => RtcManager.instance.leaveChannel();

  @override
  Future<void> openMic() => RtcManager.instance.openMic();

  @override
  Future<void> closeMic() => RtcManager.instance.closeMic();

  @override
  Future<void> setBroadcaster() async {
    await super.setBroadcaster();
    await RtcManager.instance.changeRoleToBroadcaster();
  }

  @override
  Future<void> setAudience() async {
    await super.setAudience();
    await RtcManager.instance.changeRoleToAudience();
  }

  @override
  Future<void> startPlaySong(String songCode) async {
    RtcManager.instance.startPlayAudio(songCode, false, 1, 0);
  }

  // @override
  // MusicContentCenter? get musicCenter => RtcManager.instance.musicContentCenter;

  @override
  set musicPlayerId(int id) => RtcManager.instance.musicPlayerId = id;

  @override
  Future<void> destroyMediaPlayer(MediaPlayer player) =>
      RtcManager.instance.rtcEngine.destroyMediaPlayer(player);
}
